#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QDebug>
#include <QDir>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow),
      picdir("D:\\Backup\\F盘备份\\图片")
{
    ui->setupUi(this);
    mytimer = new QTimer(this);
    mytimer->setInterval(1000);
    connect(mytimer, SIGNAL(timeout()), this, SLOT(func()));



    qDebug() << picdir.absolutePath();
    list = new QStringList(picdir.entryList());
    list->removeAll(".");
    list->removeAll("..");
    for(int i = 0; i < list->size(); i++)
    {
        qDebug() << list->at(i);
    }
    sub = 0;

}

MainWindow::~MainWindow()
{
    delete ui;
    delete list;
}


void MainWindow::on_pushButton_start_clicked()
{
    mytimer->start();
}

void MainWindow::func()
{
    qDebug() << "hello";
    QString path = QString("%1/%2").arg(picdir.absolutePath())
                            .arg(list->at((sub++)%list->size()));


    ui->label->setPixmap(path);
}


void MainWindow::on_pushButton_stop_clicked()
{
    mytimer->stop();
}

